package com.leoren.run.activity.share;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.leoren.run.R;
import com.leoren.run.vo.CommentReplay;

import java.util.List;

public class CommentReplayAdapter extends RecyclerView.Adapter<CommentReplayAdapter.ReplayHolder> {

    private Context context;
    private List<CommentReplay> replays;

    public CommentReplayAdapter(Context context, List<CommentReplay> replays) {
        this.context = context;
        this.replays = replays;
    }

    static class ReplayHolder extends RecyclerView.ViewHolder{

        LinearLayout itemLayout;
        TextView username;
        TextView content;

        public ReplayHolder(View itemView) {
            super(itemView);
            itemLayout = (LinearLayout) itemView;
            username = itemView.findViewById(R.id.item_replay_username);
            content = itemView.findViewById(R.id.item_replay_content);
        }
    }


    @Override
    public ReplayHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_comment_replay_layout, parent, false);

        return new ReplayHolder(view);
    }

    @Override
    public void onBindViewHolder(ReplayHolder holder, int position) {
        CommentReplay replay = replays.get(position);
        holder.username.setText(replay.getReplayUserName());
        holder.content.setText(replay.getContent());
    }

    @Override
    public int getItemCount() {
        return replays.size();
    }
}
